<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <title>登陆</title>
  <link rel="stylesheet" href="style.css" />
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.js"></script>
</head>

<body>



  <div id="poo" style="display: none">
    #(e)
  </div>
  <div class="box">
    <h2>登陆</h2>
    <div class="input-box">
      <label>学号</label>
      <input type="text" id='account' />
    </div>
    <div class="input-box">
      <label>密码</label>
      <input type="password" id='password' />
      <img src="image/闭眼.png" id="eyes">
    </div>
    <div class="btn-box">
      <a href="#">忘记密码?</a>
      <div>
        <button id="login">登录</button>
        <button id="regist">注册</button>
      </div>
    </div>
  </div>

  <script src="to_password.js"></script>
  <script>

    $(function () {
      $('#login').on('click', function () {
        //获取登陆的账号和密码
        var account = $('#account').val();
        var password = $('#password').val();
        var cg=document.getElementById("poo");
        console.log(cg);
        //进行ajax请求发送数据到后端进行验证
        $.post('http://localhost/student/login', {
          username: account, password: password
        }, function (res) {
          console.log(res);
          // if ((account==1&&password==1234)||(account==1&&password==2222)||(account==3206016006&&password==1234)||(account=="3206016006x"&&password=="3206016006x")){
          //   window.location.href = 'http://localhost/student?username='+account;
          // }
         //  else alert("账号或密码错误");
          if (res===true){

            window.location.href = 'http://localhost/student?username='+account;
          }else
          {

          //  window.location.href = 'http://localhost/student/login.html'
          }

        })


      })
    })

    //跳转到注册界面
    $(function () {
      $('#regist').on('click', function () {
        window.location.href = '/all/student/signUp.html';
      })
    })


    //按下回车触发登陆
    $(document).keydown(function (e) {
      if(e.which===13){
        $('#login').click();
      }
    })

  </script>
</body>

</html>